$(document).ready(function() {
	displayFaculty();
	displayProject();
	getRandomProject();
	bindingProject();
});

$(window).bind('hashchange', function() {
	location.reload();
});

function bindingProject(){
	var currentUrl = window.location.href;
	var idProject = currentUrl.slice(currentUrl.indexOf('#') + 1);
	getProjcet(idProject);
}

function getProjcet(idProject){
	var params = {
		action: 'getById',
		idProject: idProject
	};
	sendRequest(URL_PROJECT, 'GET', params, function(res){
		var data = JSON.parse(res);
		if(data){
			$('.projectTitle').text(data.Title);
			$('#projectDesc').html(data.Desc);
			$('#projectImage').attr('src', data.Image);
		}
	}, function(err){
	});
}

function getRandomProject(){
	var params = {
		action: 'getByRandom',
		fromProject: 0,
		toProject: 3
	};
	sendRequest(URL_PROJECT, 'GET', params, function(res){
		var data = JSON.parse(res);
		for(var index in data){
			$('#anotherProject').append(drawProject(data[index]));
		}
	}, function(err){
	});
}